package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: bjc
 * Date: 2025-08-17
 * Time: 11:09
 */
public class ThreadDemo15 {
    /*
    使用的是实现接口Runnable或者lambda的方式，this就不能使用，只能使用Thread.currentThread()。
     */
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            //获取当前线程的引用
            Thread t = Thread.currentThread();
            System.out.println(t.getId()+ " "+t.getName());
        },"t1");
        Thread t2 = new Thread(()->{
            //获取当前线程的引用
            Thread t = Thread.currentThread();
            System.out.println(t.getId()+ " "+t.getName());
        },"t2");

        t1.start();
        t2.start();
    }
}
